#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[25];
int n,k;
int ans;
bool isprime(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0)return 0;
    }
    return 1;

}

void dfs(int now,int now1,int sum){
    if(now==k+1){
        if(isprime(sum)){ans++;}
        return;
    }
    if(k-now>n-now1)return;
    dfs(now+1,now1+1,sum+a[now1]);
    dfs(now,now1+1,sum);
}

int main(){

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dfs(1,1,0);
    cout<<ans;
    return 0;
}